﻿#ifndef _DB_IDATASOURCE_H
#define _DB_IDATASOURCE_H

#include "udatabase/interface/idataset.h"
#include "kernel/Referenced.h"
#include "udatabase/dll_cfg.h"

namespace FD
{
	namespace Utility
	{
		namespace DB
		{
			namespace Interface
			{
				/// <summary>
				/// KeyValue集合类，其中Key类型为String，Value类型为String
				/// </summary>
				class IPropertySet;
				/// <summary>
				/// 数据集迭代器类
				/// </summary>
				class IDatasetIterator;
				/// <summary>
				/// 数据集元信息集合类
				/// </summary>
				class IDataMetaInfos;
				class IDataMetaInfo;
				/// <summary>
				/// 数据源类型枚举
				/// </summary>
				enum DataSourceType
				{
					/// <summary>
					/// 未知枚举
					/// </summary>
					DST_UNKNOWN                        = 0,
					/// <summary>
					/// 数据库数据源_矢量类型
					/// </summary>
					DST_DATABASE_VECTOR                = 1,
					/// <summary>
					/// 文件系统数据源_shapefile
					/// </summary>
					DST_FILESYSTEM_SHAPEFILE           = 2,
					/// <summary>
					/// 文件系统数据源_海图000格式
					/// </summary>
					DST_FILESYSTEM_CHART               = 3,
					/// <summary>
					/// 文件系统数据源_栅格数据格式
					/// </summary>
					DST_FILESYSTEM_RASTER              = 11,
					/// <summary>
					/// 文件系统数据源_KML文件类型
					/// </summary>
					DST_FILESYSTEM_KML                 = 12,
					/// <summary>
					/// 文件系统数据源_倾斜摄影文件类型
					/// </summary>
					DST_FILESYSTEM_OBQ				   = 13,

					DST_FILESYSTEM_VECTOR		=		14,
					/// <summary>
					/// 数据库数据源_模型类型
					/// </summary>
					DST_DATABASE_MODEL                 = 21,
					/// <summary>
					/// 数据库数据源_特效类型
					/// </summary>
					DST_DATABASE_EFFECT                = 31,
					/// <summary>
					/// 空间服务器_OGC_WMS
					/// </summary>
					DST_WEBSERVER_OGC_WMS              = 41,
					/// <summary>
					/// 空间服务器_OGC_WMTS
					/// </summary>
					DST_WEBSERVER_OGC_WMTS             = 42,
					/// <summary>
					/// 空间服务器_OGC_WFS
					/// </summary>
					DST_WEBSERVER_OGC_WFS              = 43,
					/// <summary>
					/// 空间服务器_Server
					/// </summary>
					DST_WEBSERVER_SERVER     = 51,
					/// <summary>
					/// 自定义类型
					/// </summary>
					DST_CUSTOM                         = 100,
				};

				/// <summary>
				/// 数据源类，是所有数据源类的基类。
				/// </summary>
				class FD_DB_Export IDataSource : public FD::Kernel::CReferenced
				{
				public:
					/// <summary>
					/// 默认析构函数
					/// </summary>
					/// <param name=""></param>
					/// <returns></returns>
					virtual ~IDataSource();

				public:
					/// <summary>
					/// 获取数据源别名
					/// </summary>
					/// <returns>数据源别名</returns>
					const String& getAliasName() const;
					/// <summary>
					/// 设置数据源别名
					/// </summary>
					/// <param name="aliasname">别名</param>
					/// <returns></returns>
					void setAliasName(const String& aliasname);
					/// <summary>
					/// 获取数据源名称
					/// </summary>
					/// <param name=""></param>
					/// <returns>数据源名称</returns>
					virtual String getName() const;
					/// <summary>
					/// 获取数据源类型
					/// </summary>
					/// <param name=""></param>
					/// <returns>数据源类型</returns>
					virtual INT32 getType() const;
					/// <summary>
					/// 获取数据源参数
					/// </summary>
					/// <param name=""></param>
					/// <returns>数据源KeyValue参数</returns>
					virtual FD::Utility::DB::Interface::IPropertySet* getPropertySet() const;

					/// <summary>
					/// 判断数据源是否有效
					/// </summary>
					/// <param name=""></param>
					/// <returns>是，返回true;否则，返回false</returns>
					virtual bool isValid() const;
					/// <summary>
					/// 获取指定数据集类型的数据元信息
					/// </summary>
					/// <param name=""></param>
					/// <returns>数据元信息集合对象</returns>
					virtual  FD::Utility::DB::Interface::IDataMetaInfo* getDatasetInfo(const String &name);
					/// <summary>
					/// 获取指定数据集类型的数据元信息
					/// </summary>
					/// <param name=""></param>
					/// <returns>数据元信息集合对象</returns>
					virtual  FD::Utility::DB::Interface::IDataMetaInfos* getDatasetInfos(FD::Utility::DB::Interface::DatasetType type);

					/// <summary>
					/// 获取指定数据集类型的数据集
					/// </summary>
					/// <param name=""></param>
					/// <returns>数据集的迭代器</returns>
					//virtual FD::Utility::DB::Interface::IDatasetIterator * getDatasets(FD::Utility::DB::Interface::DatasetType type);

					/// <summary>
					/// 打开指定数据集名称的数据集
					/// </summary>
					/// <param name="name">指定名称</param>
					/// <returns>数据集对象指针，如果名字不存在，这返回null</returns>
					virtual FD::Utility::DB::Interface::IDataset * openDataset(const String& name);

					/// <summary>
					/// 删除指定数据集名称的物理文件
					/// </summary>
					/// <param name="name">指定名称</param>
					/// <returns>成功删除，返回true;否则，返回false</returns>
					virtual bool deleteDataset(const String& name);

					/// <summary>
					/// 关闭指定数据集名称的数据集，会删掉数据集指针
					/// </summary>
					/// <param name="name">数据集指针</param>
					/// <returns>成功删除，返回true;否则，返回false</returns>
					virtual bool closeDataset(FD::Utility::DB::Interface::IDataset * dataset);
					/// <summary>
					/// 默认析构函数
					/// </summary>
					/// <param name=""></param>
					/// <returns></returns>
					// virtual ILayer * openLayer(String name);
					/// <summary>
					/// 序列化字符串
					/// </summary>
					/// <param name=""></param>
					/// <returns></returns>
					virtual String toXML() const;
					/// <summary>
					/// 深度拷贝
					/// </summary>
					/// <param name=""></param>
					/// <returns></returns>
					virtual FD::Utility::DB::Interface::IDataSource* clone() const;
				protected:
					/// <summary>
					/// 默认构造函数
					/// </summary>
					/// <param name=""></param>
					/// <returns></returns>
					IDataSource();
				private:
					/// <summary>
					/// 拷贝构造
					/// </summary>
					/// <param name=""></param>
					/// <returns></returns>
					IDataSource(IDataSource & datasource);
				protected:
					String mAliasName;
				};

				class FD_DB_Export IFileDataSource : public FD::Utility::DB::Interface::IDataSource
				{
				public:
					virtual ~IFileDataSource();

				protected:
					IFileDataSource();

				public:
					/// <summary>
					/// 获取目录
					/// </summary>
					/// <param name=""></param>
					/// <returns>数据源目录</returns>
					const String& getDirectory()const;

				protected:
					String mDirectory;
				};
			}
		}
	}
}

#endif
